home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / misc / pdflib / hello.c < prev    next >
C/C++ Source or Header  |  1999-01-01  |  1KB  |  48 lines

  1. /* hello.c
  2.  * Copyright (C) 1997-98 Thomas Merz. All rights reserved.
  3.  *
  4.  * PDFlib sample application
  5.  */
  6.  
  7. #include <stdio.h>
  8.  
  9. #include "pdf.h"
  10.  
  11. #define FILENAME    "hello.pdf"
  12. #define FONTNAME    "Helvetica-Bold"
  13. #define FONTSIZE    24.0
  14.  
  15. void
  16. main(int argc, char *argv[])
  17. {
  18.     FILE    *pdffile;    /* PDF output file pointer        */
  19.     PDF        *p;        /* pointer to the PDF structure        */
  20.     PDF_info    *info;        /* pointer to document info block    */
  21.     char *filename = FILENAME;
  22.     
  23.     if (argc > 1)
  24.         filename = argv[1];
  25.  
  26.     if ((pdffile = fopen(filename, WRITEMODE)) == NULL) {
  27.     fprintf(stderr, "Error: cannot open PDF file %s.\n", filename);
  28.     exit(2);
  29.     }
  30.  
  31.     info        = PDF_get_info();    /* get info block    */
  32.     info->Creator    = "hello.c";        /* and fill some    */
  33.     info->Author    = "Thomas Merz";    /* elements        */
  34.     info->Title        = "Hello, world!";
  35.  
  36.     p = PDF_open(pdffile, info);        /* open new PDF file    */
  37.  
  38.     PDF_begin_page(p, a4.width, a4.height);    /* start a new page    */
  39.     PDF_set_font(p, FONTNAME, FONTSIZE, winansi);
  40.     PDF_set_text_pos(p, 50, 700);
  41.     PDF_show(p, "Hello, world!");
  42.     PDF_end_page(p);                /* close page        */
  43.  
  44.     PDF_close(p);                /* close PDF document    */
  45.  
  46.     exit(0);
  47. }
  48.